using System;
using System.Windows.Media;
namespace Coding4Fun.Phone.Controls.Helpers
{
	public static class ColorExtentions
	{
		private static float smethod_0(float float_0, float float_1, float float_2)
		{
			return Math.Max(Math.Max(float_0, float_1), float_2);
		}
		private static float smethod_1(float float_0, float float_1, float float_2)
		{
			return Math.Min(Math.Min(float_0, float_1), float_2);
		}
		public static float GetHue(this Color color)
		{
			if (color.get_R() == color.get_G() && color.get_G() == color.get_B())
			{
				return 0f;
			}
			float num = (float)color.get_R() / 255f;
			float num2 = (float)color.get_G() / 255f;
			float num3 = (float)color.get_B() / 255f;
			float num4 = ColorExtentions.smethod_1(num, num2, num3);
			float num5 = ColorExtentions.smethod_0(num, num2, num3);
			float num6 = num5 - num4;
			float num7;
			if (num == num5)
			{
				num7 = (num2 - num3) / num6;
			}
			else
			{
				if (num2 == num5)
				{
					num7 = 2f + (num3 - num) / num6;
				}
				else
				{
					num7 = 4f + (num - num2) / num6;
				}
			}
			num7 *= 60f;
			if (num7 < 0f)
			{
				num7 += 360f;
			}
			return num7;
		}
		public static HSV GetHSV(this Color color)
		{
			return new HSV
			{
				Hue = color.GetHue(),
				Saturation = color.GetSaturation(),
				Value = color.GetValue()
			};
		}
		public static float GetSaturation(this Color color)
		{
			float float_ = (float)color.get_R() / 255f;
			float float_2 = (float)color.get_G() / 255f;
			float float_3 = (float)color.get_B() / 255f;
			float num = ColorExtentions.smethod_1(float_, float_2, float_3);
			float num2 = ColorExtentions.smethod_0(float_, float_2, float_3);
			if (num2 == num)
			{
				return 0f;
			}
			if (num2 != 0f)
			{
				return 1f - 1f * num / num2;
			}
			return 0f;
		}
		public static float GetValue(this Color color)
		{
			float float_ = (float)color.get_R() / 255f;
			float float_2 = (float)color.get_G() / 255f;
			float float_3 = (float)color.get_B() / 255f;
			return ColorExtentions.smethod_0(float_, float_2, float_3);
		}
	}
}
